<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec"
           uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<sec:authentication property="principal" var="currentPrincipal"
                    scope="page"/>

<fmt:setBundle basename="ApplicationMessage"/>
<fmt:setLocale value="zh_CN"/>

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp" %>
  <%@ include file="/WEB-INF/include/css.jsp" %>

</head>

<body class="ms-theme-blue">

<%@ include file="/WEB-INF/include/header.jsp" %>
<%@ include file="/WEB-INF/include/submenu.jsp" %>

<div class="container-fluid ms-container has-ms-sidemenu">

  <ol class="ms-breadcrumb breadcrumb">
    <li class="active">订单管理&nbsp;&nbsp;-&nbsp;&nbsp;详情</li>
  </ol>

  <div class="ms-content-layout ">

    <div class="form-horizontal ms-form form-personal-info">
      <div class="block-heading">
        <h5>订单信息</h5>
      </div>
      <div class="form-group ms-form-group">

        <label class="control-label col-xs-2" style="width: 15%;">国家：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${persist.country(order.country).chineseName}</p>
        </div>
        <label class="control-label col-xs-2" style="width: 15%;">品牌：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${persist.supplier(order.brand).chineseName}</p>
        </div>

        <label class="control-label col-xs-2" style="width: 15%;">车型：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.vehicleBrand}</p>
        </div>

      </div>

      <div class="form-group ms-form-group">

        <label class="control-label col-xs-2" style="width: 15%;">取车时间：</label>
        <div class="col-xs-2">
          <p class="form-control-static">
            <fmt:formatDate value="${order.pickupDate}"
                            pattern="yyyy-MM-dd HH:mm"/>
          </p>
        </div>

        <label class="control-label col-xs-2" style="width: 15%;">取车地点：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.pickupLocationName}</p>
        </div>


      </div>

      <div class="form-group ms-form-group">

        <label class="control-label col-xs-2" style="width: 15%;">还车时间：</label>
        <div class="col-xs-2">
          <p class="form-control-static">
            <fmt:formatDate value="${order.returnDate}"
                            pattern="yyyy-MM-dd HH:mm"/>
          </p>
        </div>
        <label class="control-label col-xs-2" style="width: 15%;">还车地点：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.returnLocationName}</p>
        </div>

        <label class="control-label col-xs-2" style="width: 15%;">套餐：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${persist.setCategorys(order.details.setMeal).chineseName}</p>
        </div>
      </div>

      <div class="form-group ms-form-group">
        <label class="control-label col-xs-2" style="width: 15%;">下单时间：</label>
        <div class="col-xs-2">
          <p class="form-control-static">
            <fmt:formatDate value="${order.createTime}"
                            pattern="yyyy-MM-dd HH:mm:ss"/>
          </p>
        </div>
        <label class="control-label col-xs-2" style="width: 15%;">到付/预付：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.type.description}</p>
        </div>

        <label class="control-label col-xs-2" style="width: 15%;">年龄：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.details.customerInfo.age}</p>
        </div>


      </div>

      <div class="form-group ms-form-group">

        <label class="control-label col-xs-2" style="width: 15%;">订单号：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.code}</p>
        </div>

        <label class="control-label col-xs-2" style="width: 15%;">alamo订单号：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.alamoCode}</p>
        </div>

        <c:if test="${not empty order.pdfUrl}">
          <label class="control-label col-xs-2" style="width: 15%;">订单确认书：</label>
          <div class="col-xs-2">
            <p class="form-control-static">
              <a href="${order.pdfUrl}" download="订单确认书.pdf">下载</a>
            </p>
          </div>
        </c:if>
      </div>

      <div class="form-group ms-form-group">

        <c:if test="${order.status.canceled}">
          <label class="control-label col-xs-2" style="width: 15%;">订单取消时间：</label>
          <div class="col-xs-2">
            <p class="form-control-static"><fmt:formatDate value="${order.cancelTime}" pattern="yyyy-MM-dd HH:mm"></fmt:formatDate></p>
          </div>
        </c:if>

        <c:if test="${order.status.canceled}">
          <label class="control-label col-xs-2" style="width: 15%;">退款时间：</label>
          <div class="col-xs-2">
            <p class="form-control-static"><fmt:formatDate value="${order.refundTime}" pattern="yyyy-MM-dd HH:mm"></fmt:formatDate></p>
          </div>
        </c:if>

      </div>

      <!--<div class="form-group ms-form-group">
        	
        	 	<label class="control-label col-xs-2" style="width: 15%;">代理：</label>
          		<div class="col-xs-2">
            		<p class="form-control-static">${order.agent.name}</p>
          		</div>
        	</div>-->

      <div class="block-heading">
        <h5>价格信息</h5>
      </div>

      <div class="form-group ms-form-group">

        <label class="control-label col-xs-2" style="width: 15%;">货币类型：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${persist.exchangeRate(order.currencyCode).currencyName}</p>
        </div>

        <label class="control-label col-xs-2" style="width: 15%;">订单金额(RMB)：</label>
        <div class="col-xs-2">
          <p class="form-control-static">
            ¥ <fmt:formatNumber value="${order.cnyPayPrice}" pattern="0.00"></fmt:formatNumber>
          </p>
        </div>

        <label class="control-label col-xs-2" style="width: 15%;">API价格：</label>
        <div class="col-xs-2">
          <p class="form-control-static">
            ${persist.exchangeRate(order.currencyCode).currencySymbol}
            <c:if test="${order.totalAmount > 0}">
              <fmt:formatNumber value="${order.totalAmount/100}"
                                pattern="0.00" type="number"/>
            </c:if>
            <c:if test="${order.totalAmount <= 0}">0</c:if>
          </p>
        </div>

      </div>

      <div class="form-group ms-form-group">

        <label class="control-label col-xs-2" style="width: 15%;">结算汇率：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.currentExchangeRate}</p>
        </div>

        <c:if test="${order.type == 'ARRIVEPAY'}">
          <label class="control-label col-xs-2" style="width: 15%;">代理返点：</label>
          <div class="col-xs-2">
            <p class="form-control-static">
              <fmt:formatNumber value="${order.agentCommission}" type="number"
                                pattern="0.00"/>
            </p>
          </div>
        </c:if>

        <label class="control-label col-xs-2" style="width: 15%;">代理返点率：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.agentRate}%</p>
        </div>
        <c:choose>
          <c:when test="${! empty order.userCouponId}">
            <label class="control-label col-xs-2" style="width: 15%;">优惠结算金额：</label>
            <div class="col-xs-2">
              <p class="form-control-static">￥<span><fmt:formatNumber
                      value="${persist.loadCnyPrice(order.id) < 0 ? '0.00':persist.loadCnyPrice(order.id)}"
                      type="number"
                      maxFractionDigits="2" pattern="0.00"/>
										</span>
              </p>
            </div>
          </c:when>
        </c:choose>


        <label class="control-label col-xs-2" style="width: 15%;">提成金额(RMB)：</label>
        <div class="col-xs-2">
          <p class="form-control-static">
            ¥ <fmt:formatNumber value="${order.distributionRewardRecord.amount / 100}"
                                pattern="0.00"></fmt:formatNumber>
          </p>
        </div>

      </div>

      <div class="form-group ms-form-group">

        <label class="control-label col-xs-2" style="width: 15%;">见闻实收金额(RMB)：</label>
        <div class="col-xs-2">
          <p class="form-control-static">
            ¥ <fmt:formatNumber value="${order.fitaActualIncome}" pattern="0.00"></fmt:formatNumber>
          </p>
        </div>

      </div>


      <div class="block-heading">
        <h5>优惠信息</h5>
      </div>
      <div class="form-group ms-form-group">
        <c:if test="${! empty order.userCouponId}">
          <label class="control-label col-xs-2" style="width: 15%;">优惠券名称：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${persist.loadUserCoupon(order.userCouponId).template.name}</p>
          </div>
          <label class="control-label col-xs-2" style="width: 15%;">优惠券码：</label>
          <div class="col-xs-2">
            <p class="form-control-static">${persist.loadUserCoupon(order.userCouponId).code}</p>
          </div>
          <label class="control-label col-xs-2" style="width: 15%;">优惠券面值：</label>
          <div class="col-xs-2">
            <p class="form-control-static">￥<fmt:formatNumber
                    value="${persist.loadUserCoupon(order.userCouponId).amount/100}" type="number"
                    maxFractionDigits="2" pattern="0.00"/>
            </p>
          </div>
          <label class="control-label col-xs-2" style="width: 15%;">最低消费：</label>
          <div class="col-xs-2">
            <p class="form-control-static">￥<fmt:formatNumber
                    value="${persist.loadUserCoupon(order.userCouponId).template.minAmount/100}" type="number"
                    maxFractionDigits="2" pattern="0.00"/>
            </p>
          </div>
        </c:if>
      </div>


      <div class="block-heading">
        <h5>客户信息</h5>
      </div>
      <div class="form-group ms-form-group">
        <label class="control-label col-xs-2" style="width: 15%;">姓名：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.customerPerfix}${order.customerName}</p>
        </div>
        <label class="control-label col-xs-2" style="width: 15%;">电邮：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.customerEmail}</p>
        </div>
        <label class="control-label col-xs-2" style="width: 15%;">航班号：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.details.customerInfo.flightNumber}</p>
        </div>
      </div>

      <div class="form-group ms-form-group">
        <label class="control-label col-xs-2" style="width: 15%;">手机号：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.customerMobile}</p>
        </div>
      </div>

      <div class="block-heading">
        <h5>附加信息</h5>
      </div>
      <div class="form-group ms-form-group">
        <c:forEach var="orderSpecialEquipment"
                   items="${orderSpecialEquipment}">
          <label class="control-label col-xs-2" style="width: 15%;"></label>
          <div class="col-xs-2">
            <p class="form-control-static">${orderSpecialEquipment.specialEquipment.chineseName}</p>
          </div>
        </c:forEach>
      </div>

      <div class="block-heading">
        <h5>支付信息</h5>
      </div>
      <div class="form-group ms-form-group">
        <label class="control-label col-xs-2" style="width: 15%;">支付方式：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.orderPayType.description}</p>
        </div>
        <label class="control-label col-xs-2" style="width: 15%;">支付流水号：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${persist.paymentRequest(order.code).payCode}</p>
        </div>
        <label class="control-label col-xs-2" style="width: 15%;">支付时间：</label>
        <div class="col-xs-2">
          <p class="form-control-static">
            <fmt:formatDate value="${order.payTime}"
                            pattern="yyyy-MM-dd HH:mm:ss"/>
          </p>
        </div>
      </div>
      <div class="form-group ms-form-group">
        <label class="control-label col-xs-2" style="width: 15%;">支付金额(RMB)：</label>
        <div class="col-xs-2">
          <p class="form-control-static">
            ￥
            <c:if test="${order.actualPayPrice > 0}">
              <fmt:formatNumber value="${order.actualPayPrice/100}"
                                pattern="0.00" type="number"/>
            </c:if>
            <c:if test="${order.actualPayPrice <= 0}">
              0
            </c:if>
          </p>
        </div>
        <label class="control-label col-xs-2" style="width: 15%;">是否退款：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.payStatus.description eq '已退款' == true ? '是':'否'}</p>
        </div>

        <c:if test="${not empty order.payPic}">
          <label class="control-label col-xs-2" style="width: 15%;">支付凭证：</label>
          <div class="col-xs-2">
            <p class="form-control-static"><a target="_blank"
                                              href="${cloudContext.domain += "/" += order.payPic}">图片</a></p>
          </div>
        </c:if>

      </div>


      <div class="form-group ms-form-group">
        <label class="control-label col-xs-2" style="width: 15%;">标记支付操作人：</label>
        <div class="col-xs-2">
          <p class="form-control-static">${order.markPayOperator.name}</p>
        </div>
      </div>

    </div>
  </div>
</div>

<%@ include file="/WEB-INF/include/script.jsp" %>
<d:resource type="script" root="${ctx.resource}/build"
            src="js/page/order/order-view.js"/>
<script type="text/javascript">
  require(['page/order/order-view'], function (page) {
    page.init()
  })
</script>

</body>
</html>